using System.Web.Mvc;
using WroxBlog.Models.Interfaces;

namespace WroxBlog.Controllers
{
    public class CategoryController : Controller
    {
        private IPostRepository _postRepository;
        private ICategoryRepository _categoryRepository;

        public CategoryController(IPostRepository postRepository,
           ICategoryRepository categoryRepository)
        {
            this._postRepository = postRepository;
            this._categoryRepository = categoryRepository;
        }

        public ActionResult CategoryIndex(string name)
        {
            ViewData["Title"] = name;
            ViewData["Posts"] = this._postRepository.GetPostsInCategory(name);
            ViewData["Categories"] = this._categoryRepository.GetCategories();

            return View();
        }
    }
}
